package com.dbsun.service.st;
import com.dbsun.common.ServerResponse;
import com.dbsun.entity.system.Page;
import com.dbsun.entity.system.PageData;
import com.dbsun.mapper.st.CommentMapper;
import com.dbsun.service.BaseService;
import com.dbsun.util.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class CommentService extends BaseService {
	@Autowired
	private CommentMapper CommentMapper;
	public List<PageData> getPageCommentList(Page page){
	return CommentMapper.getPageCommentList(page);
	}
	public ServerResponse<List<PageData>> getCommentList(PageData pd){
	if(Tools.isObjEmpty("111")){
return ServerResponse.badArgument();
	}
	return ServerResponse.createBySuccess(CommentMapper.getCommentList(pd));
	}
@Transactional
public ServerResponse<String> addComment(PageData pd) {
int rowCount = CommentMapper.addComment(pd);
if(rowCount > 0){
return ServerResponse.createBySuccessMessage("添加成功");
}
return ServerResponse.createByErrorMessage("添加失败");
}
@Transactional
	public ServerResponse<String> updateCommentByid(PageData pd) {
if(Tools.isObjEmpty(pd.get("id"))){
return ServerResponse.createByErrorMessage("修改参数错误");
}
		int rowCount = CommentMapper.updateCommentByid(pd);
if(rowCount > 0){
return ServerResponse.createBySuccessMessage("修改成功");
}
return ServerResponse.createByErrorMessage("修改失败");
}
public ServerResponse<PageData> getCommentByColumn(PageData pd) {
if(Tools.isObjEmpty(pd.get("id"))){
return ServerResponse.createByErrorMessage("获取数据参数错误");
}
return ServerResponse.createBySuccess(CommentMapper.getCommentByColumn(pd));
}
	public ServerResponse<String> deleteCommentByColumn(PageData pd) {
if(Tools.isObjEmpty(pd.get("id"))){
return ServerResponse.createByErrorMessage("删除参数错误");
}
int rowCount = CommentMapper.deleteCommentByColumn(pd);
if(rowCount > 0){
return ServerResponse.createBySuccessMessage("删除成功");
	}
		return ServerResponse.createByErrorMessage("删除失败");
	}
}
